//基础配置类型

// 引入vue-router数据类型
/**
 * RouteLocationNormalized标准化的路由地址
 * 没有任何重定向记录在导航守卫中
 * to 和 from 总是属于这种类型
 */
import type { RouteRecordRaw, RouteLocationNormalized } from "vue-router";

//全局基础样式类型
export type Layout = {
  showDrawer: boolean;
  shrink: boolean; //是否收缩布局
  layoutMode: string; //后台布局方式，可选值<Default|Classic|Streamline>
  mainAnimation: string; // 后台主页面切换动画，可选值<slide-right|slide-left|el-fade-in-linear|el-fade-in|el-zoom-in-center|el-zoom-in-top|el-zoom-in-bottom>
  isDark: boolean; // 是否暗黑模式
  menuWidth: number; // 侧边菜单宽度(展开时)，单位px
  menuDefaultIcon: string; // 侧边菜单项默认图标
  menuCollapse: boolean; // 是否水平折叠收起菜单
  menuUniqueOpened: boolean; // 是否只保持一个子菜单的展开(手风琴)
  menuShowTopBar: boolean; // 显示菜单栏顶栏(LOGO)
  menuBackground: string[]; // 侧边菜单背景色
  menuColor: string[]; // 侧边菜单文字颜色
  menuActiveBackground: string[]; // 侧边菜单激活项背景色
  menuActiveColor: string[]; // 侧边菜单激活项文字色
  menuTopBarBackground: string[]; // 侧边菜单顶栏背景色
  headerBarTabColor: string[]; // 顶栏文字色
  headerBarBackground: string[]; // 顶栏背景色
  headerBarHoverBackground: string[]; // 顶栏悬停时背景色
  headerBarTabActiveBackground: string[]; // 顶栏激活项背景色
  headerBarTabActiveColor: string[]; // 顶栏激活项文字色
  overviewLayoutMode: string; //总览侧边栏布局方式
  overviewMenuWidth: number; // 总览侧边菜单宽度(展开时)，单位px
  overviewshrink: boolean; //是否收缩布局
  overviewCollapse: boolean; // 是否水平折叠收起总览菜单
};

// 用户中心数据类型
export type MemberCenter = {
  open: boolean; // 是否开启会员中心
  layoutMode: string; // 布局模式
  activeRoute: RouteRecordRaw | RouteLocationNormalized | null; // 当前激活菜单
  viewRoutes: RouteRecordRaw[]; // 从后台加载到的菜单
  showHeadline: boolean; // 是否显示一级菜单标题(当有多个一级菜单分组时显示)
  authNode: Map<string, string[]>; // 权限节点
  shrink: boolean; // 收缩布局
  menuExpand: boolean; // 菜单展开（小屏设备）
};

//用户信息类型
export type UserInfo = {
  // id: number;
  // username: string;
  // nickname: string;
  email: string;
  // mobile: string;
  sex: string;
  // birthday: string;
  // money: number;
  // score: number;
  avatar: string;
  loginIp: string;
  loginDate: string;
  // motto: string;
  // token: string;
  // refreshToken: string;
  userId: number;
  userName: string;
  nickName: string;
  createTime: string;
  phonenumber: string;
  companyid: number;
  deptId: number;
};

// 后台登录用户信息类型
export type AdminInfo = {
  userId: number; //用户id
  userName: string; //用户名
  nickName: string; //登录账号名称
  avatar: string; //头像
  loginDate: string; //最近一次登录时间
  token: string;
  refreshToken: string;
  companyid: any;
  super: boolean; // 是否是superAdmin，用于判定是否显示终端按钮等，不做任何权限判断
};

//后台登陆权限路由数据类型
export type NavTabs = {
  activeIndex: number;
  activeRoute: RouteLocationNormalized | null;
  tabsView: RouteLocationNormalized[];
  tabFullScreen: boolean;
  tabsViewRoutes: RouteRecordRaw[];
  authNode: Map<string, string[]>;
  authNodes: any;
  aside: boolean;
  columnDisplayStoreMap: Map<string, any>;
  pageSizeMap: Map<string, any>;
};

//后台站点config类型
export type SiteConfig = {
  site_name: string;
  record_number?: string;
  version: string;
  cdn_url: string;
  api_url: string;
  upload: {
    mode: string;
    maxsize: number;
    mimetype: string;
    savename: string;
    url?: string;
    params?: any;
  };
};

interface RootObject {
  code: number;
  msg: string;
  time: number;
  data: Data;
}

interface Data {
  adminInfo: AdminInfo;
  menus: Menu[];
  siteConfig: SiteConfig;
  terminal: Terminal;
}

interface Terminal {
  install_service_port: string;
  npm_package_manager: string;
}

interface Upload {
  maxsize: number;
  savename: string;
  mimetype: string;
  mode: string;
}

//路由参数类型格式
interface Menu {
  id: number;
  pid: number;
  type: string;
  title: string;
  name: string;
  path: string;
  icon: string;
  menu_type?: string;
  url: string;
  component: string;
  keepalive: number | string;
  extend: string;
  children?: Child2[];
}

interface Child2 {
  id: number;
  pid: number;
  type: string;
  title: string;
  name: string;
  path: string;
  icon: string;
  menu_type?: string;
  url: string;
  component: string;
  keepalive: number | number | string | string;
  extend: string;
  children?: Child[];
}

interface Child {
  id: number;
  pid: number;
  type: string;
  title: string;
  name: string;
  path: string;
  icon: string;
  menu_type?: any;
  url: string;
  component: string;
  keepalive: number;
  extend: string;
}
